//logMessage(LOGLEVEL_DEBUG, "LOGGER", "", "");
#include <EEPROM.h>

/*************************************************************
 *
 * globals
 *
 *************************************************************/




void logMessage(int aLevel, String aToken, String aMessage, int aValue) {
  if (aLevel <= LOGLEVEL) {
    _logMessage(_getLogLevelAsString(aLevel), aToken, aMessage, aValue);
  }
}

void logMessage(int aLevel, String aToken, String aMessage, String aValue) {
  if (aLevel <= LOGLEVEL) {
    _logMessage(_getLogLevelAsString(aLevel), aToken, aMessage, aValue);
  }
}



/*************************************************************
 *
 * intern
 *
 *************************************************************/
 
 String _getLogLevelAsString(int aLevel) {
  String tempLogLevel = "";
  if (aLevel == LOGLEVEL_ERROR) {
    tempLogLevel = "ERROR";
  }
  if (aLevel == LOGLEVEL_INFO) {
    tempLogLevel = "INFO";
  }
  if (aLevel == LOGLEVEL_DEBUG) {
    tempLogLevel = "DEBUG";
  }
  return tempLogLevel;
}

void _logMessage(String aLogLevel, String aToken, String aMessage, String aValue) {
  Serial.print(aLogLevel);
  Serial.print(": ");
  Serial.print(aToken);
  Serial.print(": ");
  Serial.print(aMessage);
  Serial.println(aValue);
}

void _logMessageToEEPROM(int aFacility, int aAddr, int aValue) {
  if (aFacility == LOGGER_EEPROM_FACILITY) {
    EEPROM.write(aAddr, aValue);
    int value = EEPROM.read(aAddr);
  }
}

void _logMessage(String aLogLevel, String aToken, String aMessage, int aValue) {
  Serial.print(aLogLevel);
  Serial.print(": ");
  Serial.print(aToken);
  Serial.print(": ");
  Serial.print(aMessage);
  Serial.println(aValue);
}
